<template>
	<view class="question-container">
		
		<view class="content">
			<textarea 
				class="input-area" 
				v-model="content" 
				placeholder="在这里输入您想要发送的内容..." 
				:maxlength="-1"
				auto-height
			></textarea>
			
			<button class="submit-btn" @click="submitContent">发 送</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			content: '', // 文本内容
		}
	},
	methods: {
		// 提交内容
		submitContent() {
			if (!this.content.trim()) {
				uni.showToast({
					title: '内容不能为空',
					icon: 'none',
					duration: 2000
				});
				return;
			}
			
			// 显示加载中
			uni.showLoading({
				title: '发送中...'
			});
			
			this.$api.submitQuestion({
				content: this.content
			}).then(res => {
				uni.hideLoading();
				if (res && res.code == 200) {
					
					this.content = '';
                    uni.navigateBack();
                    uni.showToast({
						title: '发送成功',
						icon: 'success',
						duration: 2000
					});
				} else {
					uni.showToast({
						title: res.msg || '发送失败',
						icon: 'none',
						duration: 2000
					});
				}
			}).catch(err => {
				uni.hideLoading();
				uni.showToast({
					title: '网络异常，请重试',
					icon: 'none',
					duration: 2000
				});
			});
		}
	}
}
</script>

<style lang="scss">
.question-container {
	min-height: 100vh;
	background-color: #f7f7f7;
	
	.status-bar {
		height: var(--status-bar-height);
		width: 100%;
		background-color: #ffffff;
	}
	
	.header {
		background-color: #ffffff;
		padding: 20rpx 30rpx;
		border-bottom: 1rpx solid #eaeaea;
		
		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
		}
	}
	
	.content {
		padding: 30rpx;
		
		.input-area {
			width: 100%;
			min-height: 300rpx;
			background-color: #ffffff;
			border-radius: 12rpx;
			padding: 20rpx;
			font-size: 28rpx;
			color: #333333;
			box-sizing: border-box;
			margin-bottom: 40rpx;
			border: 1rpx solid #e5e5e5;
		}
		
		.submit-btn {
			width: 100%;
			height: 88rpx;
			line-height: 88rpx;
			background-color: #3c9cff;
			color: #ffffff;
			font-size: 32rpx;
			border-radius: 12rpx;
			margin-top: 20rpx;
			font-weight: bold;
			border: none;
			
			&:active {
				opacity: 0.8;
			}
		}
	}
}
</style>
